package com.best.servlet;

import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

/**
 * @author Jiang Akang
 * employeeId: BG435424
 * @date 2021/7/14
 **/
public class TestTomcat {

    public static void main(String[] args) throws LifecycleException {
        // 启动tomcat
        Tomcat tomcat = new Tomcat();
        tomcat.setPort(9070);
        IndexServlet servlet = new IndexServlet();
        // 重要--》让当前项目变成一个web项目
        Context context = tomcat.addWebapp("/boot", "d:\\");
        tomcat.addServlet("/spring-boot-mytest", "index", servlet);
        context.addServletMappingDecoded("/index.do", "index");
        tomcat.start();
        tomcat.getServer().await();
    }
}
